API: Add gtk_style_context_get_section()
authorBenjamin Otte <otte@redhat.com>
Wed, 11 Jan 2012 04:17:35 +0000 (05:17 +0100)
committerBenjamin Otte <otte@redhat.com>
Wed, 11 Jan 2012 14:48:54 +0000 (15:48 +0100)
This API allows querying the location where style properties were
defined. An example implementation will be committed soon.

docs/reference/gtk/gtk3-sections.txt
gtk/gtk.symbols
gtk/gtkstylecontext.c
gtk/gtkstylecontext.h

index 6f0402506f6ffd45416d2427352a15d02744fc6e..f614e684e41b72ccea53b8af5be79e1f3748b0ce 100644 (file)
@@ -5689,6 +5689,7 @@ gtk_style_context_get_style
 gtk_style_context_get_style_property
 gtk_style_context_get_style_valist
 gtk_style_context_get_valist
+gtk_style_context_get_section
 gtk_style_context_get_color
 gtk_style_context_get_background_color
 gtk_style_context_get_border_color
index 8a83719e85603d3e74c475bccbb9529f3604a14e..59df40ce7a2094e5719766a19f9ef25cb65f1af8 100644 (file)
@@ -2551,6 +2551,7 @@ gtk_style_context_get_parent
 gtk_style_context_get_path
 gtk_style_context_get_property
 gtk_style_context_get_screen
+gtk_style_context_get_section
 gtk_style_context_get_state
 gtk_style_context_get_style
 gtk_style_context_get_style_property
index 2c1d8eb383cbb0d6265ff9321827126491ecf7b7..a39cf5abfde3eb921cb5b0d1342639ab86a503fb 100644 (file)
@@ -1399,6 +1399,48 @@ gtk_style_context_remove_provider_for_screen (GdkScreen        *screen,
     }
 }
 
+/**
+ * gtk_style_context_get_section:
+ * @context: a #GtkStyleContext
+ * @property: style property name
+ *
+ * Queries the location in the CSS where @property was defined for the
+ * current @context. Note that the state to be queried is taken from
+ * gtk_style_context_get_state().
+ *
+ * If the location is not available, %NULL will be returned. The
+ * location might not be available for various reasons, such as the
+ * property being overridden, @property not naming a supported CSS
+ * property or tracking of definitions being disabled for performance
+ * reasons.
+ *
+ * Shorthand CSS properties cannot be queried for a location and will
+ * always return %NULL.
+ *
+ * Returns: %NULL or the section where value was defined
+ **/
+GtkCssSection *
+gtk_style_context_get_section (GtkStyleContext *context,
+                               const gchar     *property)
+{
+  GtkStyleContextPrivate *priv;
+  GtkStyleProperty *prop;
+  StyleData *data;
+
+  g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
+  g_return_val_if_fail (property != NULL, NULL);
+
+  priv = context->priv;
+  g_return_val_if_fail (priv->widget_path != NULL, NULL);
+
+  prop = _gtk_style_property_lookup (property);
+  if (!GTK_IS_CSS_STYLE_PROPERTY (prop))
+    return NULL;
+
+  data = style_data_lookup (context, gtk_style_context_get_state (context));
+  return _gtk_css_computed_values_get_section (data->store, _gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (prop)));
+}
+
 static const GValue *
 gtk_style_context_query_func (guint    id,
                               gpointer values)
index afdeb7b686534ae8053f9e26c54942b027b8c37f..9a76c544689189cfab6dd1ac2a3408edc9aef1fb 100644 (file)
@@ -25,6 +25,7 @@
 #define __GTK_STYLE_CONTEXT_H__
 
 #include <glib-object.h>
+#include <gtk/gtkcsssection.h>
 #include <gtk/gtkstyleprovider.h>
 #include <gtk/gtkwidgetpath.h>
 #include <gtk/gtkborder.h>
@@ -717,6 +718,8 @@ void gtk_style_context_remove_provider (GtkStyleContext  *context,
 void gtk_style_context_save    (GtkStyleContext *context);
 void gtk_style_context_restore (GtkStyleContext *context);
 
+GtkCssSection * gtk_style_context_get_section (GtkStyleContext *context,
+                                               const gchar     *property);
 void gtk_style_context_get_property (GtkStyleContext *context,
                                      const gchar     *property,
                                      GtkStateFlags    state,